<style scoped >
    .userbody .user{padding: 15px 0px 0px 25px; overflow-y: auto;  height:454px}
    .userbody .ivu-form-item .ivu-form-item-content .ivu-input-wrapper{width: 90%;}
    .userbody .ivu-form-item .ivu-form-item-content .ivu-select{width: 90%;}
    .userbody .user .ivu-form-item{margin-bottom: 15px}
    .userbody .footer{padding-bottom: 15px;text-align: center}
    .userbody .footer .save{
        padding: 6px 22px;
        background: #37b3b3;
        border: 1px solid #37b3b3;
        color: #ffffff;
    }
    .userbody .footer .save:hover{background: #019ea3;}
    .userbody .footer .clear{
        padding: 6px 22px;
        background: #c7cdcd;
        border: 1px solid #c7cdcd;
        color: #ffffff;
    }
    .jurisdictionbody .footer{padding-bottom: 25px;text-align: center}
    .jurisdictionbody .footer .save{
        padding: 6px 22px;
        background: #37b3b3;
        border: 1px solid #37b3b3;
        color: #ffffff;
    }
    .jurisdictionbody .footer .save:hover{background: #019ea3;}
    .jurisdictionbody .footer .clear{
        padding: 6px 22px;
        background: #c7cdcd;
        border: 1px solid #c7cdcd;
        color: #ffffff;
    }
    .searchuserbody .user .ivu-row{box-shadow: 0px 0px 3px 0px #cccccc; padding:8px 16px;}
    .searchuserbody .user .ivu-row .ivu-col .ivu-form-item{margin-bottom: 0px;}
</style>
<template>
    <div class="console-product">
        <Row class="position">
            <i-col :xs="12" :sm="10" :md="8" :lg="6" >
                <div class="ivu-breadcrumb">
                    <span class="ivu-breadcrumb-item-link">当前位置：</span>
                    <span class="ivu-breadcrumb-item-link">用户中心</span>
                    <span class="ivu-breadcrumb-item-separator">/</span>
                    <span class="ivu-breadcrumb-item-link">用户管理</span>
                </div>
            </i-col>
            <i-col class="fr">
                 <span>
                  <Button @click="addUserMain"><i class="iconfont cofont">&#xe649;</i> 新增</Button>
                    <Modal class-name="popup" class="userbody" @on-cancel="cancelUser('userValidate')" v-model="userModal" :mask-closable="false" width="440">
                        <p slot="header" style="color: #eeebeb;" v-drag>
                            <span v-if="addUser">新增用户</span>
                            <span v-if="editUser">编辑用户</span>
                        </p>
                        <div class="user">
                            <Form ref="userValidate"  :model="userValidate"  :rules="ruleUserCustom" label-position="left" :label-width="65">
                                <input type="hidden" name="id" v-model="userValidate.id">
                                <Form-item label="角色:" prop="roleIds">
                                    <Select v-model="userValidate.roleIds" filterable multiple>
                                        <Option v-for="option in roleIdsList" :label="option.name" :value="option.id" :key="option.id">
                                            <span>{{option.name}}</span>
                                        </Option>
                                    </Select>
                                </Form-item>
                                 <Form-item label="用户名:" prop="username">
                                     <Input v-model="userValidate.username" :disabled="disabled"></Input>
                                </Form-item>
                                <Form-item label="密码:" prop="password">
                                    <Input type="password" v-model="userValidate.password"></Input>
                                </Form-item>
                                <Form-item label="姓名:" prop="name">
                                    <Input v-model="userValidate.name"></Input>
                                </Form-item>
                                <Form-item label="员工号:" prop="ecode">
                                     <Input v-model="userValidate.ecode"></Input>
                                </Form-item>
                                <Form-item label="OA代码:" prop="oacode">
                                    <Input v-model="userValidate.oacode"></Input>
                                </Form-item>
                                <Form-item label="员工部门:" prop="department">
                                    <Input v-model="userValidate.department"></Input>
                                </Form-item>
                                <Form-item label="状态:" prop="isusable">
                                    <Radio-group v-model="userValidate.isusable">
                                        <Radio label="1">启用</Radio>
                                        <Radio label="0">禁用</Radio>
                                    </Radio-group>
                                </Form-item>
                            </Form>
                            <div class="footer">
                                <Button class="save" v-if="addUser" :loading="modal_loading" @click="saveUser('userValidate')">保存</Button>
                                <Button class="clear" v-if="addUser" @click="clearUser('userValidate')">清空</Button>
                                <Button class="save" v-if="editUser" :loading="modal_loading" @click="editSaveUser('userValidate')">保存</Button>
                            </div>
                        </div>
                        <div slot="footer"></div>
                    </Modal>
                </span>
                <Modal class-name="popup" class="searchuserbody" @on-cancel="clearUserman('searchUserValidate')" v-model="searchUserModal" :mask-closable="false" width="600">
                    <p slot="header" style="color: #eeebeb;" v-drag>
                        <span>用户详情</span>
                    </p>
                    <div class="user">
                        <Form ref="searchUserValidate"  :model="searchUserValidate" label-position="left" :label-width="80">
                            <input type="hidden" name="id" v-model="searchUserValidate.id">
                            <Row>
                                <i-col span="12">
                                    <Form-item label="用户名:" prop="username">
                                        <span>{{searchUserValidate.username}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="姓名:" prop="name">
                                        <span>{{searchUserValidate.name}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="12">
                                    <Form-item label="员工号:" prop="ecode">
                                        <span>{{searchUserValidate.ecode}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="员工部门:" prop="department">
                                        <span>{{searchUserValidate.department}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="12">
                                    <Form-item label="OA代码:" prop="oacode">
                                        <span>{{searchUserValidate.oacode}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                <Form-item label="上次登录IP:" prop="clientip">
                                    <span>{{searchUserValidate.clientip}}</span>
                                </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="12">
                                <Form-item label="创建人:" prop="createBy">
                                    <span>{{searchUserValidate.createBy}}</span>
                                </Form-item>
                                </i-col>
                                <i-col span="12">
                                <Form-item label="创建时间:" prop="createTime">
                                    <span>{{searchUserValidate.createTime == null ? '': new Date(searchUserValidate.createTime).format('yyyy-MM-dd hh:mm:ss')}}</span>
                                </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="12">
                                <Form-item label="状态:" prop="isusable">
                                    <span>{{searchUserValidate.isusable == "0" ? "禁用":"启用"}}</span>
                                </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="所属角色:" prop="roleName">
                                        <span>{{searchUserValidate.roleName}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                        </Form>
                    </div>
                    <div slot="footer"></div>
                </Modal>
            </i-col>
        </Row>
        <div class="console-product-contcent" id="contcentHeight" :style="{height:height +'px'}">
            <Form class="searchform" ref="userForm" :model="userForm" inline>
                <Form-item label="用户名:" prop="username" :label-width="50" style="width: 175px">
                    <Input v-model="userForm.username"  @on-enter="userSearch"></Input>
                </Form-item>
                <Form-item label="日期:" prop="createTime" :label-width="35" style="width: 240px">
                    <Date-picker type="daterange" v-model="userForm.createTime" :options="creatDate0ptions" style="width: 200px"></Date-picker>
                </Form-item>
                <Form-item>
                    <Button class="search" @click="userSearch">搜索</Button>
                </Form-item>
            </Form>
            <Modal v-model="delModal" class-name="delect" width="250" @on-cancel="delCancel" :mask-closable="false">
                <p slot="header" style="color: #eeebeb" v-drag>
                    <span>提示框</span>
                </p>
                <p class="delbody">
                    <i class="iconfont" style="color: #f76165;font-size: 16px;">&#xe615</i>&nbsp;&nbsp;确认删除？
                        </p>
                <div slot="footer">
                    <div class="footer">
                        <Button  class="save" :loading="delLoading" @click="delOK">确认</Button>
                        <Button class="clear" @click="delCancel">取消</Button>
                    </div>
                </div>
            </Modal>
            <Loading v-if="spinShow"></Loading>
            <Table v-if="tableShow"  stripe border :columns="userColumns" ref="userData" :data="userData"></Table>
            <Modal v-model="jurisdictionModal" class="jurisdiction" @on-cancel="canceljurisdiction"  width="600" :mask-closable="false">
                <p slot="header" style="color: #eeebeb"  v-drag>
                    <span>权限管理</span>
                </p>
                <div class="jurisdictionbody">
                    <Tree @on-check-change="selectChange" @on-select-change="selectnode" @on-toggle-expand="toggleexpand" :data="jurisdictionData" show-checkbox></Tree>
                    <div class="footer">
                        <Button class="save" :loading="modal_loading" @click="savejurisdiction">授权</Button>
                        <Button class="clear" @click="canceljurisdiction">取消</Button>
                    </div>
                </div>
                <div slot="footer"></div>
            </Modal>
        </div>
        <Row style="background-color: #ffffff;margin-top: 1px;">
            <Col>
            <div v-if="tableShow" class="tablepage clearfix">
                <div class="fl">
                    <span>共</span>
                    <span class="num">{{total}}</span>
                    <span>条记录</span>
                    <span>{{currentPage}}/{{pageTotal}}页</span>
                </div>
                <div class="fr">
                    <Page :total="total" :page-size="pageSize" :current="currentPage" placement="top" show-elevator show-sizer @on-change="changePage" @on-page-size-change="changeSize"></Page>
                </div>
            </div>
            </Col>
        </Row>
    </div>
</template>
<script>
    // 导入要用到的子组件
    import Loading from '../../components/loading'
    export default {
        data () {
            const validateroleIds = (rule, value, callback) => {
                if (value.length === 0) {
                    callback(new Error('请填写角色名'));
                } else {
                    callback();
                }
            };
            const validateusername = (rule, value, callback) => {
                var re = /^[a-zA-z,0-9]\w{1,15}$/;
                if(value === ''){
                    callback(new Error('请输入用户名'));
                }else if (re.test(value)) {
                    callback();
                } else {
                    callback(new Error('用户名由字母、数字、下划线组成，2-16位'));
                }
            };
            const validateZH = (rule, value, callback) => {
                var re = /^[0-9A-Za-z\_\-\.\/~！@#￥%……&*（）+=~!$^();'":,<>《》“”‘’：；？、?[|]*$/;
                if (re.test(value)) {
                    callback();
                } else {
                    callback(new Error('不能输入中文'));
                }
            };
            return {
                modal_loading: false,
                total: 0,//总条数
                currentPage: 1,//当前页
                pageTotal: 1,//总页数
                pageSize: 10,//默认每页显示数量
                height: 1000,//表单高度
                spinShow: true,//加载层，默认显示
                delModal: false,//删除弹窗
                delLoading:false,//删除
                delId:'',//删除id
                jurisdictionModal:false,//权限管理弹窗
                tableShow: false,//表格层，默认隐藏
                disabled:false,
                statusList:[
                    {
                        value: 'all',
                        label: '全部'
                    },
                    {
                        value: '0',
                        label: '禁用'
                    },
                    {
                        value: '1',
                        label: '启用'
                    }
                ],
                creatDate0ptions: {
                    shortcuts: [
                        {
                            text: '最近一周',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近一个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近三个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                                return [start, end];
                            }
                        }
                    ]
                },
                userForm: {//运单管理条件查询
                    username:'',
                    createTime:[new Date().getTime() - 3600 * 1000 * 24 * 7,new Date()]
                },
                userData:[],//数据
                userColumns:[
                    {
                        width:'4%',
                        title: '序号',
                        type:'index'
                    },
                    {
                        width:'14%',
                        title: '用户名',
                        key: 'username',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.username,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.username)]);
                        }
                    },
                    {
                        width:'14%',
                        title: '姓名',
                        key: 'name',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.name,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.name)]);
                        }
                    },
                    {
                        width:'16%',
                        title: '员工号',
                        key: 'ecode',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.ecode,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.ecode)]);
                        }
                    },
                    {
                        width:'12%',
                        title: 'OA代码',
                        key: 'oacode',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.oacode,
                                    placement: 'bottom-start'
                                }
                            }, [h('span', params.row.oacode)]);
                        }
                    },
                    {
                        width:'12%',
                        title: '员工部门',
                        key: 'department',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.department,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.department)]);
                        }
                    },
                    {
                        width:'4%',
                        title: '状态',
                        key: 'isusable',
                        render: (h, params) => {
                            return h('div', [
                                params.row.isusable == 0 ?
                                    h('Tooltip', {
                                        props: {
                                            content: '禁用',
                                            placement:"bottom-start"
                                        }
                                    }, JSON.parse(localStorage.getItem("userInfo")).username == "admin"  || params.row.username != "admin"? [h('i',
                                        {
                                            class:'iconfont icon-suo',
                                            style:{
                                                cursor:'pointer',
                                                color: '#f76165'
                                            },
                                            on: {
                                                click: () => {
                                                    this.toggleUserFav(params.row)
                                                }
                                            }
                                    })] : [h('i',
                                        {
                                            class:'iconfont icon-suo',
                                            style:{
                                                cursor:'pointer',
                                                color: '#f76165'
                                            }
                                        })])
                                     :
                                    h('Tooltip', {
                                        props: {
                                            content: '启用',
                                            placement:"bottom-start"
                                        }
                                    }, JSON.parse(localStorage.getItem("userInfo")).username == "admin"  || params.row.username != "admin"? [h('i',
                                        {
                                            class:'iconfont icon-suo1',
                                            style:{
                                                cursor:'pointer',
                                                color: '#37b3b3'
                                            },
                                            on: {
                                                click: () => {
                                                    this.toggleUserFav(params.row)
                                                }
                                            }
                                        })] : [h('i',
                                        {
                                            class:'iconfont icon-suo1',
                                            style:{
                                                cursor:'pointer',
                                                color: '#37b3b3'
                                            }
                                        })])
                            ]);
                        }
                    },
                    {
                        width:'24%',
                        title: '操作',
                        key: 'id',
                        render: (h, params) => {
                            return h('div', [
                                h('Button',
                                    {
                                        class:"blue",
                                        on: {
                                            click: () => {
                                                this.openUserMain(params.row.id)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-chakan'
                                        }),
                                        h("span",'查看')
                                    ]),
                                JSON.parse(localStorage.getItem("userInfo")).username == "admin"  || params.row.username != "admin" ?
                                h('Button',
                                    {
                                        class:"blue",
                                        on: {
                                            click: () => {
                                                this.editUserMain(params.row.id)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-bianji'
                                        }),
                                        h("span",'编辑')
                                    ]) :"",
                                JSON.parse(localStorage.getItem("userInfo")).username == "admin"  || params.row.username != "admin" ?
                                h('Button',
                                    {
                                        class:"red",
                                        on: {
                                            click: () => {
                                                this.remove(params.row.id)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-qingkong'
                                        }),
                                        h("span",'删除')
                                    ]) : "",
                                JSON.parse(localStorage.getItem("userInfo")).username == "admin"  || params.row.username != "admin"?
                                h('Button',
                                    {
                                        class:"blue",
                                        on: {
                                            click: () => {
                                                this.openjuris(params.row.id)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-kshouquanjiaose'
                                        }),
                                        h("span",'授权')
                                    ]) : ""
                            ]);
                        }
                    }
                ],
                userModal:false,//新增窗口弹窗
                addUser:false,//新增
                editUser:false,//编辑
                userValidate:{//新增数据
                    id:'',
                    roleIds:[],
                    username:'',
                    password:'',
                    roleName:'',
                    name:'',
                    ecode:'',
                    oacode:'',
                    department:'',
                    isusable:'1'
                },
                ruleUserCustom:{//验证
                    roleIds: [
                        {required: true, validator: validateroleIds, trigger: 'change'}
                    ],
                    username: [
                        {required: true, validator: validateusername, trigger: 'blur'},
                        {type: 'string', max: 50, message: '用户名最大长度不能超过50位', trigger: 'blur'}
                    ],
                    password: [
                        {required: true, message: '请输入密码', trigger: 'blur'},
                        {type: 'string', max: 32, message: '密码最大长度不能超过32位', trigger: 'blur'}
                    ],
                    name: [
                        {required: true, message: '请输入姓名', trigger: 'blur'},
                        {type: 'string', max: 30, message: '姓名最大长度不能超过30位', trigger: 'blur'}
                    ],
                    ecode: [
                        {required: true, message: '请输入员工号', trigger: 'blur'},
                        {type: 'string', validator: validateZH, trigger: 'blur'},
                        {type: 'string', max: 50, message: '员工号最大长度不能超过50位', trigger: 'blur'}
                    ],
                    oacode: [
                        {required: true, message: '请输入OA代码', trigger: 'blur'},
                        {type: 'string', validator: validateZH, trigger: 'blur'},
                        {type: 'string', max: 20, message: 'OA代码最大长度不能超过20位', trigger: 'blur'}

                    ],
                    department: [
                        {required: true, message: '请输入员工部门', trigger: 'blur'},
                        {type: 'string', max: 50, message: '员工部门最大长度不能超过50位', trigger: 'blur'}
                    ]
                },
                jurisdictionData:[],
                searchUserModal:false,//查看弹窗
                searchUserValidate:{
                    id:'',
                    username:'',
                    name:'',
                    oacode:'',
                    department:'',
                    ecode:'',
                    clientip:'',
                    createBy:'',
                    isusablename:'',
                    createTime:'',
                    isusable:''
                },
                roleIdsList: [],//角色名
                jurisdiction:{
                    memberId:'',
                    permissionIds:''
                },
                idList:'',
            }
        },
        //所需子组件
        components: {
            Loading
        },
        created:function(){
            var width = window.innerWidth;
            if(width >1600){
                this.height=window.innerHeight-200;
            }else if(width > 1440 && width <=1600){
                this.height=window.innerHeight-180;
            }else if(width > 1366 && width <=1440){
                this.height=window.innerHeight-172;
            }else if(width > 1280 && width <=1366){
                this.height=window.innerHeight-166;
            }else if(width > 1024 && width <=1280){
                this.height=window.innerHeight-162;
            }else{
                this.height=window.innerHeight-151;
            }
            if(window.innerWidth > 1600){
                this.pageSize=20;
            }
            this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize)
        },
        mounted() {

        },
        methods: {
            //查询物流数据，条件，当前页，每页显示多少条
            userTableData (formData,currentPage,pageSize) {
                this.spinShow=true;
                this.tableShow = false;
                var username = formData.username;//用户名
                var fromDate = '';//开始时间
                var toDate = '';//结束时间
                if(formData.createTime.length != 0  && formData.createTime[0] != null && formData.createTime[1] != null && formData.createTime[0] != "" && formData.createTime[1] != ""){
                    var fromDateTime = (new Date(formData.createTime[0])).getTime();
                    fromDate = new Date(fromDateTime).format("yyyy-MM-dd");
                    var toDateTime = (new Date(formData.createTime[1])).getTime();
                    toDate = new Date(toDateTime).format("yyyy-MM-dd");
                }
                let data = {
                    params: {
                        pageIndex : currentPage,
                        pageSize : pageSize,
                        username : username,
                        fromDate : fromDate,
                        toDate : toDate
                    }
                };
                axios.get('/members',data).then(res => {
                    this.total=res.data.total;
                    this.pageTotal=Math.ceil(res.data.total / pageSize);
                    this.userData = res.data.data;
                    this.spinShow=false;
                    this.tableShow = true;
                }).catch(err =>{
                })
            },
            //条件查询
            userSearch () {
                this.currentPage = 1;
                this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize);
            },
            //改变页数
            changePage: function (page) {
                this.currentPage=page;
                this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize);
            },
            //改变每页显示多少条
            changeSize: function (pageSize) {
                this.currentPage = 1;
                this.pageSize = pageSize;
                this.pageTotal=Math.ceil(this.total / this.pageSize);
                this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize);
            },
            //根据ID删除用户管理
            remove(column){
                this.delModal=true;
                this.delId = column;
            },
            delOK(){
                this.delLoading = true;
                axios.delete('/members/'+this.delId).then(res => {
                    this.$Message.success('删除成功');
                    this.delLoading = false;
                    this.delModal=false;
                    this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize);
                }).catch(err =>{
                    this.delLoading = false;
                });
            },
            delCancel() {
                this.delModal=false;
                this.delId = '';
            },
            //改变状态
            toggleUserFav (row) {
                row.isusable = row.isusable ==  '0' ?'1' : '0';
                axios.put('/member/'+row.id+'/'+row.isusable, row).then(res => {
                    this.userData[row._index].isusable = this.userData[row._index].isusable == '0' ?'1' : '0';
                }).catch(err =>{
                });
            },
            //新增用户
            addUserMain() {
                axios.get('/roles',{params: {pageIndex : null,pageSize : null}}).then(res => {
                    this.roleIdsList = res.data;
                }).catch(err =>{
                });
                this.addUser = true;
                this.editUser = false;
                this.userModal=true;
                this.disabled= false;
            },
            //保存新增用户
            saveUser(name){
                this.modal_loading = true;
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.userValidate.roleIds = this.userValidate.roleIds.join(",");
                        axios.post('/members', this.userValidate).then(res => {
                            this.modal_loading = false;
                            this.userModal = false;
                            this.addUser = false;
                            this.$refs[name].resetFields();
                            this.$Message.success('新增成功');
                            this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize);
                        }).catch(err =>{
                            this.$Message.error({content: err,duration: 0,closable:true});
                            this.userValidate.roleIds = this.userValidate.roleIds.split(",");
                            var dataIntArr=[];//保存转换后的整型字符串
                            dataIntArr=this.userValidate.roleIds.map(function(data){
                                return +data;
                            });
                            this.userValidate.roleIds = dataIntArr;
                            this.modal_loading = false;
                        });
                    } else {
                        this.modal_loading = false;
                    }
                })
            },
            //根据ID编辑用户
            editUserMain(column) {
                axios.get('/roles',{params: {pageIndex : null,pageSize : null}}).then(res => {
                    this.roleIdsList = res.data;
                }).catch(err =>{
                });
                this.addUser = false;
                this.editUser = true;
                this.disabled= true;
                axios.get('/members/'+column).then(res => {
                    this.userValidate = res.data;
                    if(res.data.roleList.length != 0){
                        this.userValidate.roleIds = [];
                        for (var i =0;i<res.data.roleList.length;i++){
                            this.userValidate.roleIds.push(res.data.roleList[i].id)
                        }
                    }
                    this.userModal=true;
                }).catch(err =>{
                })
            },
            //保存编辑
            editSaveUser (name) {
                this.modal_loading = true;
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.userValidate.roleIds = this.userValidate.roleIds.join(",");
                        axios.put('/members',this.userValidate).then(res => {
                            this.modal_loading = false;
                            this.userModal = false;
                            this.editUser=false;
                            this.$refs[name].resetFields();
                            this.$Message.success('编辑成功');
                            this.userData = this.userTableData(this.userForm,this.currentPage,this.pageSize);
                        }).catch(err =>{
                            this.$Message.error({content: err,duration: 0,closable:true});
                            this.userValidate.roleIds = this.userValidate.roleIds.split(",");
                            var dataIntArr=[];//保存转换后的整型字符串
                            dataIntArr=this.userValidate.roleIds.map(function(data){
                                return +data;
                            });
                            this.userValidate.roleIds = dataIntArr;
                            this.modal_loading = false;
                        });
                    } else {
                        this.modal_loading = false;
                    }
                });
            },
            //清空新增用户信息
            clearUser(name){
                this.userValidate = {
                    id:'',
                    roleIds:[],
                    username:'',
                    password:'',
                    name:'',
                    isusable:'1'
                };
            },
            //关闭新增用户信息
            cancelUser(name){
                this.modal_loading = false;
                this.userModal = false;
                this.addUser = false;
                this.editUser = false;
                this.$refs[name].resetFields();
            },
            //授权
            openjuris(column){
                this.jurisdiction.memberId = column;
                axios.get('/member/'+column+'/tree').then(res => {
                    this.jurisdictionData = res.data;
                    this.jurisdictionModal = true;
                    setTimeout(() => {//防止父节点没选中
                        $(".ivu-tree ul.ivu-tree-children ul.ivu-tree-children ul.ivu-tree-children li label.ivu-checkbox-wrapper:first").click();
                        $(".ivu-tree ul.ivu-tree-children ul.ivu-tree-children ul.ivu-tree-children li label.ivu-checkbox-wrapper:first").click();
                    }, 500);
                }).catch(err =>{
                })
            },
            //选择授权节点
            selectChange(selection) {
                if(selection.length==0){
                    this.idList = "";
                }else{
                    this.idList = "";
                    for(var i in selection){
                        if(selection[i].id != undefined){
                            this.idList += selection[i].id + ",";
                        }
                    }
                }
            },
            selectnode(selection){
                var str = this.idList;
                $(".ivu-tree-title").each(function() {
                    if($(this).text() == selection[0].title){
                        if($(this).prev().find("span.ivu-checkbox").hasClass("ivu-checkbox-indeterminate")){
                            str += selection[0].id + ",";
                        }
                    }
                })
                this.idList = str;
            },
            toggleexpand(selection){
            },
            //取消授权
            canceljurisdiction(){
                this.jurisdictionModal = false;
                this.jurisdictionData=[];
                this.jurisdiction = {
                    memberId:'',
                    permissionIds:''
                };
                this.idList = "";
            },
            //保存授权
            savejurisdiction(){
                this.modal_loading = true;
                if(this.idList == ""){
                    $(".ivu-checkbox").each(function() {
                        if(!$(this).hasClass("ivu-checkbox-checked") && !$(this).hasClass("ivu-checkbox-indeterminate")){//没有选择
                            $(this).click();
                            $(this).click();
                            return false;
                        }
                    });
                }
                $(".ivu-checkbox-indeterminate").each(function () {
                    $(this).parent().next().click();
                });
                if (this.idList.length > 0) {
                    this.idList = this.idList.substring(0, this.idList.length - 1);
                    Array.prototype.unique = function () {
                        var res = [];
                        var json = {};
                        for (var i = 0; i < this.length; i++) {
                            if (!json[this[i]]) {
                                res.push(this[i]);
                                json[this[i]] = 1;
                            }
                        }
                        return res;
                    };
                    if(this.idList.length != 0){
                        var arr = this.idList.split(",");
                        this.idList = arr.unique().join(",");
                    }
                    this.jurisdiction.permissionIds = this.idList;
                    axios.put('/permission/putMember',this.jurisdiction).then(res => {
                        this.modal_loading = false;
                        this.jurisdictionModal = false;
                        this.jurisdictionData=[];
                        this.jurisdiction = {
                            memberId:'',
                            permissionIds:''
                        };
                        this.idList = "";
                    }).catch(err =>{
                        this.idList = "";
                        this.$Message.error({content: err,duration: 0,closable:true});
                        this.modal_loading = false;
                    });
                }else{
                    this.$Message.error("至少选择一个");
                    this.modal_loading = false;
                }
            },
            //查看详情
            openUserMain(column){
                axios.get('/members/'+column).then(res => {
                    this.searchUserValidate = res.data;
                    this.searchUserModal=true;
                    this.roleName = res.data;
                }).catch(err =>{
                })
            },
            //关闭查看详情
            clearUserman(name){
                this.searchUserModal = false;
                this.$refs[name].resetFields();
            }
        }
    }
</script>